import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const state = {
  isAuthenticated: false,
  user: null,
  openId: '',
  lessonInfo: null
};

export default new Vuex.Store({
  state,
  getters: {
    user: (state) => {
      state.user
    },
    isAuthenticated: (state) => {
      state.isAuthenticated
    }
  },
  mutations: {
    setIsAuthenticated: (state, data) => {
      state.isAuthenticated = data;
    },
    setUser: (state, data) => {
      state.user = data;
    }
  },

  actions: {
    setIsAuthenticated: (content, data) => {
      content.commit('setIsAuthenticated', data);
    },
    setUser: (content, data) => {
      content.commit('setUser', data);
    }
  }
});
